﻿using System;
using System.Web;
using System.Data;
using System.Collections.Generic;

using VIT.Web.UI;
using VIT.Web.Controls;
using VIT.Provider;
using VIT.DataHelper.DataAccess;
using VIT.Wedding;

namespace VIT.Web.Admin
{
    public partial class Home : VITComponent
    {
        public CompanyDetail company;

        protected void Page_Load(object sender, EventArgs e)
        {
            LoadWebConfig();
            LoadTemplateConfig();
            LoadPositionConfig();
            LoadLanguageConfig();
            LoadFunctionConfig();

            if (!Page.IsPostBack)
            {
                Sttt.Online = GetGlobalResourceObject("Web", "Online").ToString();
                Sttt.ToDay = GetGlobalResourceObject("Web", "ToDay").ToString();
                Sttt.Yesterday = GetGlobalResourceObject("Web", "Yesterday").ToString();
                Sttt.ThisWeek = GetGlobalResourceObject("Web", "ThisWeek").ToString();
                Sttt.LastWeek = GetGlobalResourceObject("Web", "LastWeek").ToString();
                Sttt.ThisMonth = GetGlobalResourceObject("Web", "ThisMonth").ToString();
                Sttt.LastMonth = GetGlobalResourceObject("Web", "LastMonth").ToString();
                Sttt.All = GetGlobalResourceObject("Web", "All").ToString();

                Sttt.IconOnline = URLTemplatePath + "images/thongke/Online.jpg";
                Sttt.IconToDay = URLTemplatePath + "images/thongke/today.png";
                Sttt.IconYesterday = URLTemplatePath + "images/thongke/yesterday.png";
                Sttt.IconThisWeek = URLTemplatePath + "images/thongke/thisweek.jpg";
                Sttt.IconLastWeek = URLTemplatePath + "images/thongke/lastweek.jpg";
                Sttt.IconThisMonth = URLTemplatePath + "images/thongke/thismonth.png";
                Sttt.IconLastMonth = URLTemplatePath + "images/thongke/lastmonth.png";
                Sttt.IconAll = URLTemplatePath + "images/thongke/all.jpg";

                Sttt.BinData();

                company = VITData.GetObject<CompanyDetail>(o => o.Id == 1);
            }
        }

        private void LoadWebConfig()
        {
            VIT.Provider.WebConfig wc = new VIT.Provider.WebConfig();
            wc.LanguageId = Session["language"].ToString();
            gvwWebConfig.DataSource = wc.GetConfig();
            gvwWebConfig.DataBind();
        }

        private void LoadTemplateConfig()
        {
            VIT.Provider.TemplateConfig tc = new VIT.Provider.TemplateConfig();
            tc.LanguageId = Session["language"].ToString();
            gvwTemplateConfig.DataSource = tc.GetAll();
            gvwTemplateConfig.DataBind();
        }

        private void LoadPositionConfig()
        {
            VIT.Provider.Position pos = new VIT.Provider.Position();
            gvwPositionConfig.DataSource = pos.getAll();
            gvwPositionConfig.DataBind();
        }

        private void LoadLanguageConfig()
        {
            VIT.Provider.Language l = new VIT.Provider.Language();
            gvwLanguageConfig.DataSource = l.getAll();
            gvwLanguageConfig.DataBind();
        }

        private void LoadFunctionConfig()
        {
            VIT.Provider.Function f = new VIT.Provider.Function();
            gvwFunctionConfig.DataSource = f.getAll();
            gvwFunctionConfig.DataBind();
        }
    }
}
    